class FriendNotifier < ActionMailer::Base
  def signup_notification(friend, config)
    setup_email(friend, nil)
    @subject    += 'Please activate your eternal friendship'
    @body[:url]  = "http://#{config[:url]}/account/activate/#{friend.activation_code}"
  end
  
  def activation(friend)
    setup_email(friend, nil)
    @subject    += 'Your eternal friendship has been activated!'
    @body[:url]  = "http://#{config[:url]}/"
  end
  
  def lostpassword(friend, config)
    setup_email(friend, config)  
    @subject += 'Remembering a password'    
  end
  
  protected
  def setup_email(friend, config)
    @recipients  = "#{friend.email}"
    @from        = "#{config[:email]}" unless config.nil?
    @subject     = "[#{config[:url]}] " unless config.nil?
    @sent_on     = Time.now
    @body[:friend] = friend
  end
end
